package com.xiaogao.sys.controller;

import com.xiaogao.common.entity.PageData;
import com.xiaogao.common.entity.Result;
import com.xiaogao.security.annotation.HasPerm;
import com.xiaogao.sys.request.log.login.QueryParam;
import com.xiaogao.sys.response.SysLogLoginResponse;
import com.xiaogao.sys.service.SysLogLoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sys/log/login")
@RequiredArgsConstructor
public class SysLogLoginController {
    private final SysLogLoginService sysLogLoginService;

    @PostMapping("/list")
    public Result<PageData<SysLogLoginResponse>> querySelective(@RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                                @RequestParam(required = false, defaultValue = "30") Integer pageSize,
                                                                @RequestBody QueryParam queryParam){
        PageData<SysLogLoginResponse> pageData = sysLogLoginService.querySelective(pageNum,pageSize,queryParam);
        return Result.success(pageData);
    }

    @HasPerm("sys:log:login:delete")
    @PostMapping("/delete")
    public Result<Object> delete(@RequestBody List<String> ids) {
        sysLogLoginService.delete(ids);
        return Result.success();
    }
}
